﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Net;
//using System.Text;
//using System.IO;
//using System.Runtime.Serialization;
////using SXT.Utility;


//namespace ZHDJ.MobileInterface.Push
//{
//    public class GovernmentServicesCloudSMSHelper
//    {
//        public static string SendMessage(string requestUrl, GovernmentServicesCloudSMSSendInParam inParam)
//        {
//            #region post
                      
//            string returnStr = string.Empty;
//            StreamWriter sw = File.AppendText(ServiceSettings.LogFilePath + "GovernmentServicesCloudSMSSendLog_" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
//            sw.WriteLine("========接口调用开始========");
//            sw.WriteLine("党建调用政务云短信平台发送接口："+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));            
           
//            try
//            {
//                string strURL = requestUrl;
//                System.Net.HttpWebRequest request;
//                request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
//                //Post请求方式
//                request.Method = "POST";
//                //请求超时时间
//                request.Timeout = 100 * 1000;//执行超时时间为10秒
//                // 内容类型
//                request.ContentType = "application/x-www-form-urlencoded";
//                // 参数经过URL编码 
//                string paraUrlCoded = string.Format(@"SpCode={0}&LoginName={1}&Password={2}&MessageContent={3}&UserNumber={4}&SerialNumber={5}
//                                                      &ScheduleTime={6}&ExtendAccessNum={7}&f={8}", inParam.SpCode, inParam.LoginName, inParam.Password, inParam.MessageContent,
//                                                      inParam.UserNumber, inParam.SerialNumber, inParam.ScheduleTime, inParam.ExtendAccessNum,inParam.f);

//                sw.WriteLine("请求路径："+strURL + paraUrlCoded);

//                byte[] payload;
//                //将URL编码后的字符串转化为字节
//                //payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
//                payload = System.Text.Encoding.GetEncoding("gb2312").GetBytes(paraUrlCoded);
//                //设置请求的 ContentLength
//                request.ContentLength = payload.Length;
//                //获得请求流
//                Stream writer = request.GetRequestStream();
//                //将请求参数写入流
//                writer.Write(payload, 0, payload.Length);
//                // 关闭请求流
//                writer.Close();

//                //接收相应
//                System.Net.HttpWebResponse response;
//                // 获得响应流
//                response = (System.Net.HttpWebResponse)request.GetResponse();
//                System.IO.Stream s;
//                s = response.GetResponseStream();
//                //StreamReader readStream = new StreamReader(s, Encoding.UTF8);
//                StreamReader readStream = new StreamReader(s, Encoding.GetEncoding("gb2312"));
//                string responseStr = readStream.ReadToEnd();

//                sw.WriteLine("请求响应结果：" + responseStr);
//                sw.WriteLine("========接口调用结束========");
//                sw.Close();
//                sw.Dispose();

//                return responseStr;
//            }
//            catch (Exception ex)
//            {
//                ExceptionLogs.Write(new Exception("党建调用政务云发短信接口时发生异常：" + ex.Message.ToString()));
//                sw.WriteLine("发生异常：" + ex.Message + ":" + ex.StackTrace);
//                sw.WriteLine("========接口调用结束========");
//                sw.Close();
//                sw.Dispose();

//                return "-1";
//            }
            
//            #endregion

////            #region get

////                string returnStr = string.Empty;
////                StreamWriter sw = File.AppendText(ServiceSettings.LogFilePath + "GovernmentServicesCloudSMSSendLog_" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
////                sw.WriteLine("========接口调用开始========");
////                sw.WriteLine("党建调用政务云短信平台发送接口：" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));

////                try
////                {
////                    string strURL = requestUrl;
////                    string paraUrlCoded =requestUrl+string.Format(@"?SpCode={0}&LoginName={1}&Password={2}&MessageContent={3}&UserNumber={4}&SerialNumber={5}
////                                                          &ScheduleTime={6}&ExtendAccessNum={7}&f={8}", inParam.SpCode, inParam.LoginName, inParam.Password, inParam.MessageContent,
////                                                         inParam.UserNumber, inParam.SerialNumber, inParam.ScheduleTime,inParam.ExtendAccessNum
////                                                        inParam.f);
////                    sw.WriteLine("请求路径：" + paraUrlCoded);
////                    System.Net.HttpWebRequest request;
////                    request = (System.Net.HttpWebRequest)WebRequest.Create(paraUrlCoded);
////                    //get请求方式
////                    request.Method = "get";

////                    //服务器对上面请求的返回结果。由于是web service,返回是xml文件，所以使用下面的方式接收显示
////                    System.Net.HttpWebResponse response;
////                    response = (System.Net.HttpWebResponse)request.GetResponse();
////                    System.IO.Stream s;
////                    s = response.GetResponseStream();
////                    StreamReader readStream = new StreamReader(s, Encoding.UTF8);
////                    string responseStr = readStream.ReadToEnd();

////                    sw.WriteLine("请求响应结果：" + responseStr);
////                    sw.WriteLine("========接口调用结束========");
////                    sw.Close();
////                    sw.Dispose();

////                    return responseStr;
////                }
////                catch (Exception ex)
////                {
////                    ExceptionLogs.Write(new Exception("党建调用政务云发短信接口时发生异常：" + ex.Message.ToString()));
////                    sw.WriteLine("发生异常：" + ex.Message + ":" + ex.StackTrace);
////                    sw.WriteLine("========接口调用结束========");
////                    sw.Close();
////                    sw.Dispose();

////                    return "-1";
////                }
////            #endregion

//        }

//        public class GovernmentServicesCloudSMSSendInParam
//        {
//            /// <summary>
//            /// 企业编号
//            /// </summary>
//            public string SpCode { get; set; }

//            /// <summary>
//            /// 用户名称
//            /// </summary>
//            public string LoginName { get; set; }

//            /// <summary>
//            /// 用户密码
//            /// </summary>
//            public string Password { get; set; }

//            /// <summary>
//            /// 短信内容, 最大1000个字符（短信内容要求的编码为gb2312或gbk）
//            /// </summary>
//            public string MessageContent { get; set; }

//            /// <summary>
//            /// 手机号码(多个号码用”,”分隔)，最多1000个号码
//            /// </summary>
//            public string UserNumber { get; set; }

//            /// <summary>
//            /// 流水号，20位数字，唯一 （规则自定义,建议时间格式精确到毫秒）
//            /// </summary>
//            public string SerialNumber { get; set; }

//            /// <summary>
//            /// 预约发送时间，格式:yyyyMMddhhmmss,如‘20090901010101’，立即发送请填空（预约时间要写当前时间5分钟之后的时间，若预约时间少于5分钟，则即时发送）
//            /// </summary>
//            public string ScheduleTime { get; set; }

//            /// <summary>
//            /// 接入号扩展号（默认不填，扩展号为数字，扩展位数由当前所配的接入号长度决定，整个接入号最长20位）
//            /// </summary>
//            public string ExtendAccessNum { get; set; }

//            /// <summary>
//            /// 提交时检测方式1 --- 提交号码中有效的号码仍正常发出短信，无效的号码在返回参数faillist中列出不为1 
//            ///或该参数不存在 --- 提交号码中只要有无效的号码，那么所有的号码都不发出短信，所有的号码在返回参数faillist中列出
//            /// </summary>
//            public string f { get; set; }

//        }      
//    }
//}